package com.jtny.nytb.datafilling.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.jtny.component.entity.WebResponse;
import com.jtny.nytb.datafilling.service.EnergyPriceConfigService;
import com.jtny.nytb.datafilling.vo.EnergyPriceConfigParamVO;
import com.jtny.nytb.datafilling.vo.HistoryEnergyPriceParamVO;
import com.jtny.nytb.datafilling.vo.HistoryEnergyPriceVO;
import com.jtny.nytb.datafilling.vo.InstitutionEquipmentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 能源价格配置填报Controller类
 *
 * @author 智慧能源中心-罗霄林
 * @version 1.0
 * @package com.jtny.nytb.energymonitor.datafilling.controller
 * @fileName EnergyPriceConfigController.java
 * @createTime 2023年09月04日 16:13
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@RestController
@Api(value = "能源价格配置填报", tags = "能源价格配置填报")
@ApiSort(20230901)
public class EnergyPriceConfigController {

    @Autowired
    private EnergyPriceConfigService energyPriceConfigService;

    @ApiOperation("本月价格配置保存")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParam(name = "energyPriceConfigParamVO", value = "本月用电价格配置保存", required = true, paramType = "query", dataType = "EnergyPriceConfigParamVO")
    @PostMapping("/saveEnergyPriceConfigInfo")
    @ResponseBody
    WebResponse<Boolean> saveEnergyPriceConfigInfo(@RequestBody EnergyPriceConfigParamVO energyPriceConfigParamVO) {
        return WebResponse.success(energyPriceConfigService.saveEnergyPriceConfigInfo(energyPriceConfigParamVO));
    }

    @ApiOperation("历史价格配置查询")
    @ApiOperationSupport(order = 2)
    @ApiImplicitParam(name = "historyEnergyPriceParamVO", value = "历史价格配置查询", required = true, paramType = "query", dataType = "HistoryEnergyPriceParamVO")
    @PostMapping("/queryHistoryEnergyPriceConfigInfo")
    @ResponseBody
    WebResponse<List<HistoryEnergyPriceVO>> queryHistoryEnergyPriceConfigInfo(@RequestBody HistoryEnergyPriceParamVO historyEnergyPriceParamVO) {
        return WebResponse.success(energyPriceConfigService.queryHistoryEnergyPriceConfigInfo(historyEnergyPriceParamVO));
    }


    @ApiOperation("保存制度和设备的关系")
    @PostMapping("/saveOrUpdateRealtion")
    public WebResponse<?> saveOrUpdateRealtion(@RequestBody List<InstitutionEquipmentVO> list){
        energyPriceConfigService.saveOrUpdateRealtion(list);
        return WebResponse.success();
    }

    @ApiOperation("删除制度和设备的关系")
    @DeleteMapping("/removeRealtion/{ids}")
    public WebResponse<?> removeRealtion(@PathVariable("ids") List<Long> ids){
        energyPriceConfigService.removeRealtion(ids);
        return WebResponse.success();
    }

    @ApiOperation("查询制度和设备的关系")
    @GetMapping("/getInstitutionEquipment")
    public WebResponse<?> getInstitutionEquipment(InstitutionEquipmentVO institutionEquipmentVO){
        return WebResponse.success(energyPriceConfigService.getInstitutionEquipment(institutionEquipmentVO));
    }

}
